package com.k.kc.common.resp;

import java.time.LocalDateTime;
import java.util.List;

public class ErrorResult {
    private String code;
    private String message;

    private String path;
    private LocalDateTime timestamp;
    private List<?> errors;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public LocalDateTime getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(LocalDateTime timestamp) {
        this.timestamp = timestamp;
    }

    public List<?> getErrors() {
        return errors;
    }

    public void setErrors(List<?> errors) {
        this.errors = errors;
    }

    public static <E> ErrorResult format(String code, String msg, String path, List<E> errors) {
        ErrorResult result = new ErrorResult();
        result.setCode(code);
        result.setMessage(msg);
        result.setPath(path);
        result.setTimestamp(LocalDateTime.now());
        result.setErrors(errors);
        return result;
    }
}
